#ifndef HEADER_MAP
#define HEADER_MAP

#include "Player.h"
#include "Building.h"
#include "OwnedBuilding.h"
#include "Entity.h"
#include "SugarDrop.h"
#include "Equipment.h"
#include "Fruit.h"
#include <time.h>
#include <fstream>

#include <iostream>

class Map
{
	public:
		Map();

        void addNewModification(std::vector<int> modif);
        void addUpdatedModificationObject(std::vector<int> modif);
        void addUpdatedModificationSugar(std::vector<int> modif);
        void addDeletedModification(std::vector<int> modif);
        void addMovedModification(std::vector<int> modif);
        void addSugar(Player *player, int quantity);

        int addSugarDrop(int x, int y, int quantity);
        void removeEntity(Entity *entity);
        void addEntity(Entity *entity);
        void moveEntity(Entity *entity, int x, int y);

        std::pair<int,int> getValidSquare(int x, int y, int distance);
        Equipment* createEquipment(int equipmentType, int x, int y);
        int createFruit(int fruitType, int x, int y, Player *owner);
        void createPlayers(int nbPlayers);

        int verifyId(int id);
        bool contains(int x, int y);
        bool isWall(int x, int y);
        bool verifyPosition(int x, int y);
        Entity* getEntity(int id);
        bool verifyBuilding(Fruit *fruit, int buildingType);
        bool verifySource();
        void addSourceMiner();
        void resetSourceMiner();

        void createWalls(int x0, int y0, int x1, int y1);

        void setWidth(int w);
        void setHeight(int h);
        void setCurrentId(int id);
        std::vector<Player*> getListPlayers();

        std::string printC();

	protected:
        std::vector<Player*> listPlayers;
        std::multimap<std::pair<int,int>, Entity* > mapPositions;
        std::map<int,Entity*> mapIds;
        std::set<std::pair<int, int> > mapWalls; //true = WALL

        int currentId;
        int nbSourceMiner;
        int width;
        int height;

        int idVitaminSource;
        int idSugarTree;

};


#endif
